package com.example.service.impl;


import com.example.mapper.LogMapper;
import com.example.pojo.OperateLog;
import com.example.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper logMapper;

    public Map<String, Object> pageQuery(Integer page, Integer pageSize) {
        // 计算分页参数
        Map<String, Object> params = new HashMap<>();
        params.put("offset", (page - 1) * pageSize);
        params.put("pageSize", pageSize);

        // 查询数据
        List<OperateLog> rows = logMapper.pageQuery(params);

        // 查询总记录数
        int total = logMapper.count(params);

        // 组装返回结果
        Map<String, Object> result = new HashMap<>();
        result.put("total", total);
        result.put("rows", rows);

        return result;
    }
}
